home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbasicpg.zip
/
MAXSALES.BAS
< prev
next >
Wrap
BASIC Source File
|
1989-08-31
|
2KB
|
56 lines
' MAXSALES.BAS
' This program reads salesperson data into three arrays and displays
' the salesperson with the highest total sales. The maximum number
' of names that can be entered is 50; fewer can be entered by
' typing "END" for the salesperson name.
OPTION BASE 1 ' set base of all arrays to 1
DIM salesGroup$(50) ' dimension salesGroup$ string array
DIM bikesSold%(50) ' dimension bikesSold% integer array
DIM totalSales!(50) ' dimension totalSales! floating-point array
CLS
PRINT "Follow prompts to enter bike shop data. Type END to quit."
PRINT
count% = 1 ' initialize an array counter variable
WHILE (salesGroup$(count%) <> "END") ' continue until name = "END"
INPUT "Enter salesperson name: ", salesGroup$(count%)
IF (salesGroup$(count%) <> "END") THEN
INPUT " Bikes sold: ", bikesSold%(count%)
INPUT " Total sales: $", totalSales!(count%)
PRINT
count% = count% + 1 ' increment the array counter
END IF
WEND
largest! = totalSales!(1) ' first array element is largest so far
lg% = 1 ' save array index
' compare remaining array elements for something bigger--if one is
' found, assign it to largest! and save the array index in lg%; if
' there is a tie for the largest, return the first element found
FOR i% = 2 TO count% - 1
IF (totalSales!(i%) > largest!) THEN
largest! = totalSales!(i%) ' save new largest value
lg% = i% ' save array index
END IF
NEXT i%
' initialize tmp$, a formatting template for PRINT USING
tmp$ = "\ \ ### $$####.##"
PRINT
PRINT "** "; salesGroup$(lg%); " has the highest total sales **"
PRINT
PRINT "Salesperson Bikes sold Total sales"
PRINT "------------------------------------------"
PRINT
PRINT USING tmp$; salesGroup$(lg%); bikesSold%(lg%); totalSales!(lg%)